# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class WeiboItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    id = scrapy.Field()
    fans_counts = scrapy.Field()
    follow_count = scrapy.Field()
    profile_image_url = scrapy.Field()
    profile_url = scrapy.Field()
    screen_name = scrapy.Field()
    description = scrapy.Field()
    verified_reason = scrapy.Field()
    mbrank = scrapy.Field()
    tags = scrapy.Field()
    genders = scrapy.Field()
    crawled_time = scrapy.Field()

    def save_to_mysql(self):
        sql = 'insert into weibo(fans_counts,follow_count,profile_image_url,profile_url,screen_name,description,verified_reason,mbrank,tags,genders,crawled_time)' \
              'values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
        data=(self["fans_counts"],self["follow_count"],self["profile_image_url"],self["profile_url"],self["screen_name"],self["description"],self["verified_reason"],self["mbrank"],self["tags"],self["genders"],self["crawled_time"])
        return sql,data

class ArtilceItem(scrapy.Item):
    id = scrapy.Field()
    attitudes_count = scrapy.Field()
    comments_count = scrapy.Field()
    reposts_count = scrapy.Field()
    source = scrapy.Field()
    text = scrapy.Field()
    user = scrapy.Field()
    created_at = scrapy.Field()